<?php
/*
考试记录管理模块
*/
include_once('include/top.php');

$action=fs_get_value("do");
$id=fs_get_value("id");
switch($action)
{
	case	"delete"	:	delete($id)	;	break;
	default				:	main()		;	break;
}




//***********************************************************
//**********************管理文章*****************************
//***********************************************************
function delete($id){
   global $db;
   $result=$db->query("delete from fooeeexam_exam_record where record_id=".$id);
   $result? fs_showmsg("删除成功!"):fs_showmsg("删除过程中出现错误,请检查!");

}
function main()
{
	global $db;
	global $dbmain;

	//取总条数
	$sql = "select * from fooeeexam_exam_record";
	$result = $db->query($sql);
	$resultcount = $db->num_rows($result);
	//pagebar
	$page=fs_get_value('p');							//接收页码
	if ($page==null){$page=1;}
	$pagesize=10;								//每页显示数
	$pagecount=ceil($resultcount/$pagesize);	//计算总页
	if ($page>$pagecount){$page=$pagecount;}
	if ($page<1){$page=1;}
	$startnum=($page-1)*($pagesize);
	//pagebarend
?>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
    <th class="CTitle">习题管理</th>
  </tr>
  <tr>
    <td class="CPanel">
		<div class="SubMenu">
			<a href="admin_test.php?">习题管理</a> | 
			<a href="admin_test.php?do=addtest">添加习题</a> | 
			<a href="?">习题记录</a>
		</div>
            <div align="left" style="padding:5px;" id="box">
               <table border="0" cellpadding="0" cellspacing="0" class="TablePanel" align="center" width="100%">
					<tr align="center">
					  <td class="TDHead" nowrap>习题名称</td>   
                      <td class="TDHead" nowrap>学生姓名</td>
					  <td class="TDHead" nowrap>答题时间</td>
					  <td class="TDHead" nowrap>操作记录</td>
	                </tr>
<?php
	$result=$db->query("select r.*,e.exam_name from fooeeexam_exam_record as r inner join fooeeexam_exam as e on r.record_exam_id=e.exam_id order by record_exam_id DESC limit ".$startnum.",$pagesize ");
	while($row = $db->fetch_array($result))
	{
		$exam_name = $row['exam_name'];
?>
		<tr  onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='FFFFFF'" title=单击选中 align="center">
			<td height=20><?php echo(get_test_name($row['record_exam_id']));?></td>
			<td><?php echo(fs_get_memberinfo($row['record_member_id'],'realname'));?></td>
			<td><?php echo($row['record_data']);?></td>
			<td><a href="?do=delete&id=<?php echo $row['record_id'];?>">删除</a></td>
		</tr>
		<tr>
			<td height=1 colspan=9 bgcolor="#E8F1FF" onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='E7E7E7'"></td>
		</tr>
<?php
	}	
?>
	</table>	
	</div>
	
<center>
<?php
/*分页示例:

pager(传入URL , 数据总数 , 开始条数 , 每页数目)
*/
echo(pager('?p={page}',$resultcount,$startnum,$pagesize));		
?>
	</center>
	</td>
	</tr>
	</table>
<?php
}
function get_test_name($test_id){
	global $db;
	$sql = "select * from fooeeexam_exam where exam_id = ".$test_id;
	$result = $db -> query($sql);
	$row = $db -> fetch_array($result);
	return $row['exam_name'];
}
?>

